package com.xbongbong.paas.service;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.pojo.dto.DepartmentFlatListDTO;
import com.xbongbong.paas.pojo.dto.DepartmentGetDTO;
import com.xbongbong.paas.pojo.dto.DepartmentListDTO;
import com.xbongbong.paas.pojo.dto.DepartmentSimpleListDTO;
import com.xbongbong.paas.pojo.dto.ImportFormDataDTO;
import com.xbongbong.paas.pojo.vo.DepartmentFlatListVO;
import com.xbongbong.paas.pojo.vo.DepartmentGetVO;
import com.xbongbong.paas.pojo.vo.DepartmentListVO;
import com.xbongbong.paas.pojo.vo.DepartmentSimpleListVO;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.department.pojo.dto.DepartmentListRelatedDTO;
import com.xbongbong.pro.department.pojo.dto.DepartmentUserListDTO;
import com.xbongbong.pro.department.pojo.vo.DepartmentListRelatedVO;
import com.xbongbong.pro.department.pojo.vo.DepartmentUserListVO;
import com.xbongbong.sys.domain.entity.DepartmentEntity;

import java.util.List;
import java.util.Map;

/**
 * 部门Service
 *
 * @author kaka
 * @time 2018-9-10 11:33
 */
public interface DepartmentService {

    /**
     * 部门列表
     *
     * @param departmentListDTO 关联业务DTO
     * @return 关联业务VO
     * @throws XbbException 业务异常
     */
    DepartmentListVO list(DepartmentListDTO departmentListDTO) throws XbbException;

    /**
     * 获取平铺的部门列表，无层级结构，支持分页
     *
     * @param departmentFlatListDTO 关联业务DTO
     * @return 关联业务VO
     * @throws XbbException 业务异常
     */
    DepartmentFlatListVO flatList(DepartmentFlatListDTO departmentFlatListDTO) throws XbbException;

    /**
     * 部门列表，简单格式
     * [{
     * "value" : 1,
     * "label" : "一级部门",
     * "children" : [{
     * "value" : 11,
     * "label" : "二级部门1"
     * },{
     * "value" : 12,
     * "label" : "二级部门2"
     * }]
     * }]
     *
     * @param simpleListDTO 关联业务DTO
     * @return 关联业务VO
     * @throws XbbException 业务异常
     */
    DepartmentSimpleListVO simpleList(DepartmentSimpleListDTO simpleListDTO) throws XbbException;

    /**
     * 部门数据
     *
     * @param departmentGetDTO
     * @return
     * @throws XbbException
     */
    DepartmentGetVO getByDepartmentIds(DepartmentGetDTO departmentGetDTO) throws XbbException;

    /**
     * 是否从缓存内读取标记：false-不从缓存读取，true-从缓存读取
     *
     * @param ifJedis
     */
    void setIfJedis(boolean ifJedis);

    /**
     * 获取某公司所有部门列表--先从缓存内获取，缓存内没有则查询数据库，然后存入缓存
     *
     * @param corpid 公司ID
     * @return
     */
    List<DepartmentEntity> getAllDepList(String corpid);

    /**
     *
     * @author 吴峰
     * @date 2019/6/24 14:53
     * @param departmentListRelatedDTO
     * @return com.xbongbong.pro.department.pojo.vo.DepartmentListRelatedVO
     * @throws XbbException 业务异常
     */
    DepartmentListRelatedVO relatedList(DepartmentListRelatedDTO departmentListRelatedDTO) throws XbbException;

    /**
     * 校验导入部门
     *
     * @param importFormDataDTO
     * @param dataList
     * @return
     * @throws XbbException
     */
    Long verifyDepartment(ImportFormDataDTO importFormDataDTO, Map<String, FieldAttrEntity> explainMap, JSONObject dataList) throws XbbException;

    /**
     * 获取部门和用户列表
     * @param departmentUserListDTO
     * @date 2020-02-12 16:26
     * @return
     * @throws XbbException
     */
    DepartmentUserListVO departmentUserList(DepartmentUserListDTO departmentUserListDTO) throws XbbException;
}
